<template>
	<view class="">
		<view class="bac_f" style="border-top: 1px solid rgba(0, 0, 0, 0.1);">
			<u-tabs
				lineWidth="45"
				lineColor="#F14537"
				:list="orderList"
				@click="tabClick"
				itemStyle="padding-left: 140rpx; padding-right:140rpx; height: 42px;"
				:activeStyle="{
					color: '#F14537',
					fontWeight: 'bold',
					transform: 'scale(1.05)'
				}"
				:inactiveStyle="{
					color: '#999999',
					transform: 'scale(1)'
				}"
			></u-tabs>
		</view>
		<view class="ml24 mr24 bac_f padding30 mt36 p_re" v-for="(item,index) in wait_list" :key="index">
			<view v-show="current==0" class="p_ab" style="top: 0; right: 0"><image style="width: 80rpx; height:80rpx" src="/static/image/red_d.png" mode=""></image></view>
			<view
				v-show="current==0"
				class="p_ab tf"
				style="
			    font-size: 16rpx;
			    top: 22rpx;
			    right: 6rpx;
			    transform: rotate(45deg);
			  "
			>
				{{item.group_purchase.num}}人团
			</view>
			<view class="dis_f">
				<image class="w180 h180 radius12" :src="item.group_purchase.image" mode="aspectFill"></image>
				<view class="ml24" style="min-width: 438rpx;">
					<view class="fw fz30">{{item.group_purchase.name}}</view>
					<view v-show="current==0" class="fz24 fw mt8 radius20 h36 tf_666">
						已参与1人，还差
						<text class="tf_4537 fz24">2</text>
						人拼团成功
					</view>
					<view v-show="current==1" class="fz26 mt8 radius20 h36 tf_666">
						预约时间：
					</view>
					<view class="dis_flex ac mt16">
						<view v-show="current==0" class=""><uni-countdown :show-day="false" :hour="2" :minute="30" :second="0" color="#FD395C" background-color="#FFF0F2" /></view>
						<view v-show="current==1" class="tf_22 fw fz20">
							2人拼团成功
						</view>
						<view class="dis_f">
							<view class="fz24 fw" style="color: #FE3737;">拼团价</view>
							<view class="fz36 fw ml12">¥{{item.group_purchase.price}}</view>
						</view>
					</view>
				</view>
			</view>
			<view class="dis_f je">
				<view v-show="current==0" class="fz24 w156 radius8 tf_33 dis_f jc mt24 mr24 w156 border7" style="height: 58rpx;">取消订单</view>
				<view v-show="current==1" class="fz24 w156 radius8 tf_33 dis_f jc mt24 w156 border7" style="height: 58rpx;">查看详情</view>
				<view v-show="current==0" class="fz24 w156 radius8 tf_4537 dis_f jc mt24 border4537" style="height: 58rpx;width: 204rpx;" @click="friendG(item)">邀请好友拼单</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { groupWaitList,groupSuccList } from "@/config/api.js";
export default {
	data() {
		return {
			current: 0,
			orderList: [{ name: '待成团' }, { name: '已成团' }],
			wait_list:[],
		};
	},
	onLoad() {
		this.getWaitList()
	},
	methods: {
		//邀请好友
		friendG(e){
			uni.navigateTo({
				url:'../groupInvite/groupInvite?id='+e.id
			})
		},
		tabClick(item) {
			console.log(item);
			if(item.index==0){
				this.current=0
				this.getWaitList()
			}else{
				this.current=1
				groupSuccList().then(res=>{
					this.wait_list = res
				})
			}
		},
		//获取待成团数据
		getWaitList(){
			groupWaitList().then(res=>{
				console.log(res);
				this.wait_list = res
			})
		},
	}
};
</script>

<style></style>
